<template>
	<view>
		<view>
			<u--form labelPosition="left" :model="pile" ref="uForm">
				<u-form-item label="充电桩编号" prop="pilesId" borderBottom ref="item1">
					<u--text v-model="pile.pilesId" border="none"></u--text> 
				</u-form-item>
				<u-form-item label="充电桩名称" prop="pilesName" borderBottom ref="item2">
					<u--text v-model="pile.pilesName" border="none"></u--text> 
				</u-form-item>
				<u-form-item label="充电桩功率" prop="rateOfWork" borderBottom ref="item3">
					<u--text v-model="pile.rateOfWork" border="none"></u--text> 
				</u-form-item>
				<u-form-item label="充电桩电流方式" prop="current" borderBottom ref="item4">
					<u--text v-model="pile.current" border="none"></u--text> 
				</u-form-item>
				<u-form-item label="充电桩状态" prop="state" borderBottom ref="item5">
					<u--text v-model="pile.state" border="none"></u--text> 
				</u-form-item>
				<u-form-item label="充电桩创建时间" prop="createTime" borderBottom ref="item6">
					<u--text v-model="pile.createTime" border="none"></u--text> 
				</u-form-item>
				<u-form-item label="充电枪" prop="pile.guns" borderBottom ref="item7">
					<u-button :text="pile.guns.gunId+' '+pile.guns.state+' '+pile.guns.gunName" @click="pile.guns=item"></u-button>
					<u--text :text="item.gunId+' '+item.state+' '+item.gunName"></u--text>
				</u-form-item>
				<u-form-item label="当前所在充电站编号" prop="pile.station" borderBottom ref="item8">
					<u--text :text="pile.station.stationId"></u--text>
				</u-form-item>
				<u-form-item label="当前所在充电站名字" prop="pile.station" borderBottom ref="item9">
					<u--text :text="pile.station.stationName"></u--text>
				</u-form-item>
				<u-form-item label="当前所在充电站所在地址" prop="pile.station" borderBottom ref="item10">
					<u--text :text="pile.station.address"></u--text>
				</u-form-item>
				<u-form-item label="当前所在充电站有无空位" prop="pile.station" borderBottom ref="item11">
					<u--text :text="pile.station.status"></u--text>
				</u-form-item>
			</u--form>
		</view>
		<u-button type="primary" text="充电" :disabled="disabled"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pile: {
					pilesId:"",
					pilesName:"",
					rateOfWork:"",
					current:"",
					state:"",
					createTime:"",
					guns:{},
					station:{}
				},
				item:{},
				disabled:true
			}
		},
		methods: {
			
		},
		onShow() {
			let that = this;
			
			let pilesId=uni.getStorageSync("pilesId");
			that.str =pilesId;
			
			uni.request({
				method:'GET',
				header:{
					'content-type':'application/json;charset:utf-8'
				},
				url: "http://localhost:8081/piles/getOnePile?pilesId="+pilesId,
				success(res) {
					that.pile = res.data.data;
				}
			})
			
			uni.request({
				url:"/upi/piles/isCharge",
				success(res) {
					if(res.data.code==200){
						that.$refs.uToast.show({
							type: 'success',
							message: "充电枪连接成功"
						})
						uni.removeStorageSync("pilesId");
						that.disabled=false
					}else{
						that.$refs.uToast.show({
							type: 'default',
							message: "充电枪连接未成功,请检查连接"
						})
					}
				}
			})
		}
	}
</script>

<style>

</style>